Skip to content

feat(registry): add Google Sign-In script#573

Merged
harlan-zw merged 1 commit intomainfrom
feat/google-sing-in
Jan 15, 2026
Merged

feat(registry): add Google Sign-In script#573
harlan-zw merged 1 commit intomainfrom
feat/google-sing-in

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Jan 15, 2026

🔗 Linked issue

#381

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds Google Sign-In (Google Identity Services) as a registry script with:

  • useScriptGoogleSignIn composable with full GIS API support
  • One Tap prompt for streamlined authentication
  • Personalized "Sign in with Google" button via renderButton
  • FedCM API support (Privacy Sandbox - mandatory from August 2025)

- Add useScriptGoogleSignIn composable with full GIS API support
- One Tap, personalized button, and automatic sign-in flows
- FedCM API support (Privacy Sandbox, mandatory Aug 2025)
- Moment notifications for tracking One Tap display state
- Comprehensive TypeScript types for all GIS interfaces
- Interactive docs demo with live sign-in testing
- E2E test and playground example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
scripts-docs Ready Ready Preview, Comment Jan 15, 2026 1:27pm
scripts-playground Ready Ready Preview, Comment Jan 15, 2026 1:27pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/scripts/@nuxt/scripts@573

commit: ae8559f

}

export const GoogleSignInOptions = object({
clientId: string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clientId field in the GoogleSignInOptions schema is marked as required, but the documented pattern for registry-based script loading doesn't provide it to the composable, causing validation errors in development mode.

View Details
📝 Patch Details
diff --git a/docs/content/scripts/utility/google-sign-in.md b/docs/content/scripts/utility/google-sign-in.md
index 152d7ac..25f1787 100644
--- a/docs/content/scripts/utility/google-sign-in.md
+++ b/docs/content/scripts/utility/google-sign-in.md
@@ -123,7 +123,7 @@ You can configure the Google Sign-In script with the following options:
 
 ```ts
 export const GoogleSignInOptions = object({
-  clientId: string(),
+  clientId: optional(string()),
   autoSelect: optional(boolean()),
   context: optional(union([literal('signin'), literal('signup'), literal('use')])),
   useFedcmForPrompt: optional(boolean()),
diff --git a/src/runtime/registry/google-sign-in.ts b/src/runtime/registry/google-sign-in.ts
index 696b7b3..a72e39e 100644
--- a/src/runtime/registry/google-sign-in.ts
+++ b/src/runtime/registry/google-sign-in.ts
@@ -107,7 +107,7 @@ export interface GoogleSignInApi {
 }
 
 export const GoogleSignInOptions = object({
-  clientId: string(),
+  clientId: optional(string()),
   // Auto-select credentials if only one is available
   autoSelect: optional(boolean()),
   // Context for One Tap (signin, signup, or use)

Analysis

Missing optional() wrapper on clientId field in GoogleSignInOptions schema

What fails: In src/runtime/registry/google-sign-in.ts, the clientId field in GoogleSignInOptions is defined as string() (required). When following the documented pattern of using googleSignIn: true in nuxt.config.ts with environment variable-based configuration, the composable receives an empty object {}. This causes schema validation to fail in development mode because clientId is marked required but not provided.

How to reproduce:

// nuxt.config.ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      googleSignIn: true,  // No clientId provided here
    }
  },
  runtimeConfig: {
    public: {
      scripts: {
        googleSignIn: {
          clientId: '', // Will be set via NUXT_PUBLIC_SCRIPTS_GOOGLE_SIGN_IN_CLIENT_ID
        },
      },
    },
  },
})

Running the app in development mode generates: Invalid key: Expected "clientId" but received undefined when schema validation is triggered (line 143 of google-sign-in.ts: schema: import.meta.dev ? GoogleSignInOptions : undefined).

Result: Validation error appears in development when following the documented registry pattern with environment variables.

Expected: Schema validation should pass with empty object, as clientId can be provided externally (via runtime config, environment variables, or to accounts.id.initialize() separately). Made clientId optional in the schema by wrapping with optional() to match the actual use case where clientId may be provided through other configuration sources.

Fix: Changed clientId: string() to clientId: optional(string()) in:

  • src/runtime/registry/google-sign-in.ts (line 110)
  • docs/content/scripts/utility/google-sign-in.md (line 126)

This aligns with the documented pattern in google-sign-in.md which shows googleSignIn: true without providing clientId in the config object.

@harlan-zw
Copy link
Collaborator Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@harlan-zw harlan-zw merged commit 3b4e676 into main Jan 15, 2026
10 checks passed
@harlan-zw harlan-zw deleted the feat/google-sing-in branch January 15, 2026 13:37
@harlan-zw harlan-zw mentioned this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant